1
|
|
|
import {MigrationInterface, QueryRunner} from "typeorm"; |
2
|
|
|
|
3
|
|
|
export class Shooting1618659343512 implements MigrationInterface { |
4
|
|
|
name = 'Shooting1618659343512' |
5
|
|
|
|
6
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> { |
7
|
|
|
await queryRunner.query(`ALTER TABLE "photo" DROP CONSTRAINT "FK_92a92cf6e76017c70a95170a540"`); |
8
|
|
|
await queryRunner.query(`CREATE TYPE "shooting_status_enum" AS ENUM('enabled', 'disabled')`); |
9
|
|
|
await queryRunner.query(`CREATE TABLE "shooting" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "shootingDate" date NOT NULL, "closingDate" date NOT NULL, "status" "shooting_status_enum" NOT NULL DEFAULT 'disabled', "schoolId" uuid NOT NULL, CONSTRAINT "PK_f41f1588cd6d69dca794f93c8f4" PRIMARY KEY ("id"))`); |
10
|
|
|
await queryRunner.query(`ALTER TABLE "school" DROP COLUMN "pdv"`); |
11
|
|
|
await queryRunner.query(`ALTER TABLE "photo" DROP COLUMN "schoolId"`); |
12
|
|
|
await queryRunner.query(`ALTER TABLE "photo" ADD "token" character varying NOT NULL`); |
13
|
|
|
await queryRunner.query(`ALTER TABLE "photo" ADD "shootingId" uuid NOT NULL`); |
14
|
|
|
await queryRunner.query(`ALTER TABLE "shooting" ADD CONSTRAINT "FK_35765c057b260a030d29b812281" FOREIGN KEY ("schoolId") REFERENCES "school"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); |
15
|
|
|
await queryRunner.query(`ALTER TABLE "photo" ADD CONSTRAINT "FK_e4a158e221f64fd303021454b51" FOREIGN KEY ("shootingId") REFERENCES "shooting"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); |
16
|
|
|
await queryRunner.query(`DROP TABLE "access_token"`); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> { |
20
|
|
|
await queryRunner.query(`ALTER TABLE "photo" DROP CONSTRAINT "FK_e4a158e221f64fd303021454b51"`); |
21
|
|
|
await queryRunner.query(`ALTER TABLE "shooting" DROP CONSTRAINT "FK_35765c057b260a030d29b812281"`); |
22
|
|
|
await queryRunner.query(`ALTER TABLE "photo" DROP COLUMN "shootingId"`); |
23
|
|
|
await queryRunner.query(`ALTER TABLE "photo" DROP COLUMN "token"`); |
24
|
|
|
await queryRunner.query(`ALTER TABLE "photo" ADD "schoolId" uuid NOT NULL`); |
25
|
|
|
await queryRunner.query(`ALTER TABLE "school" ADD "pdv" TIMESTAMP`); |
26
|
|
|
await queryRunner.query(`DROP TABLE "shooting"`); |
27
|
|
|
await queryRunner.query(`DROP TYPE "shooting_status_enum"`); |
28
|
|
|
await queryRunner.query(`ALTER TABLE "photo" ADD CONSTRAINT "FK_92a92cf6e76017c70a95170a540" FOREIGN KEY ("schoolId") REFERENCES "school"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|